package com.cat.dataStructure;

import java.io.*;

/**
 * @author 曲大人的喵
 * @description https://www.luogu.com.cn/problem/P3368
 * @create 2025/9/28 12:29
 * @since JDK17
 */
// 范围增加，单点查询
public class Solution88 {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StreamTokenizer in = new StreamTokenizer(br);
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static int N = ((int) (5e5 + 2)), n, m;
    static int[] tree = new int[N];
    static void add(int i, int v) {
        for (; i <= n; i += i & -i) {
            tree[i] += v;
        }
    }
    static int sum(int i) {
        int ans = 0;
        for (; i > 0; i -= i & -i) {
            ans += tree[i];
        }
        return ans;
    }


    public static void main(String[] args) throws IOException {
        in.nextToken();
        n = ((int) in.nval);
        in.nextToken();
        m = ((int) in.nval);
        for (int i = 1; i <= n; i++) {  // 以差分的形式来构造树状数组
            in.nextToken();
            int num = ((int) in.nval);
            add(i, num);
            add(i + 1, -num);
        }
        for (int i = 0; i < m; i++) {
            in.nextToken();
            int opt = ((int) in.nval), l, r , v;
            if (opt == 1) {
                in.nextToken();
                l = ((int) in.nval);
                in.nextToken();
                r = ((int) in.nval);
                in.nextToken();
                v = ((int) in.nval);
                add(l, v);
                add(r + 1, -v);
            } else {
                in.nextToken();
                l = ((int) in.nval);
                out.println(sum(l));
            }
        }

        out.flush();
        out.close();
        br.close();;
    }
}
